 import React from 'react'
import { Router, Route, hashHistory,IndexRoute } from 'react-router';

import MyWallet from    '../containers/Wallet/myWallet'
import Bmikece from     '../containers/Wallet/Bmikece'
import Transfer from     '../containers/Wallet/Transfer'
import BankCardList from     '../containers/Wallet/BankCardList'
import AddBankCard from     '../containers/Wallet/AddBankCard'
import Deposit from     '../containers/Wallet/Deposit'
import AutoDeposit from     '../containers/Wallet/AutoDeposit'
import DanluJsBridge from 'common/jsBridge'

import NotFound from    '../containers/404'

// 如果是大型项目，router部分就需要做更加复杂的配置
// 参见 https://github.com/reactjs/react-router/tree/master/examples/huge-apps


// const MyWallet = asyncComponent(() => import("../containers/Wallet/myWallet"));
// const Bmikece = asyncComponent(() => import("../containers/Wallet/Bmikece"));
// const Transfer = asyncComponent(() => import("../containers/Wallet/Transfer"));
// const BankCardList = asyncComponent(() => import("../containers/Wallet/BankCardList"));
// const AddBankCard = asyncComponent(() => import("../containers/Wallet/AddBankCard"));
// const Deposit = asyncComponent(() => import("../containers/Wallet/Deposit"));
// const NotFound = asyncComponent(() => import("../containers/404"));


// 路由进入前，功能尚待改善
const routerEnter= (nextState, replace) => {
    console.info('routerenter', nextState)
}

class RouterMap extends React.Component {
    constructor(props, context) {
        super(props, context);
        this.state = {
            roleType : 'dlzdd'
        }
    }
    componentWillMount(){
        var _this = this;
        DanluJsBridge.callHandler('getSessionData', {
          keys: ['user']
        }, function(result) {
            _this.setState({
                roleType : result.roleType
            })
        })
    }
    render() {
        return (
                <div className={this.state.roleType}>
                    <Router history={hashHistory} >
                        <Route path='/' >
                            <IndexRoute  component={MyWallet} unsuppotWallet={null}/>
                            <Route path='/bmikece' component={Bmikece} />
                            <Route path='/bankCardList' component={BankCardList} />
                            <Route path='/addBankCard' component={AddBankCard} />
                            <Route path='/transfer' component={Transfer} />
                            <Route path='/deposit' component={Deposit} />
                            <Route path='/autoDeposit' component={AutoDeposit} />
                            <Route path='*' component={NotFound} />
                        </Route>
                    </Router>
                </div>
        )
    }
}

export default RouterMap
